﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using Win104.Common;

namespace Win104
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {

            //byte[] b1 = new byte[4];
            //b1[0] = Convert.ToByte("3E",16);
            //b1[1] = Convert.ToByte("90", 16);
            //b1[2] = Convert.ToByte("E5", 16);
            //b1[3] = Convert.ToByte("60", 16);
            //float f1 = BitConverter.ToSingle(b1, 0);


            //string s = "3F67EF9D";
            //MatchCollection matches = Regex.Matches(s, @"[0-9A-Fa-f]{2}");
            //byte[] bytes = new byte[matches.Count];
            //for (int i = 0; i < bytes.Length; i++)
            //    bytes[i] = byte.Parse(matches[i].Value, System.Globalization.NumberStyles.AllowHexSpecifier);
            //float m = BitConverter.ToSingle(bytes.Reverse().ToArray(), 0);
            //Console.WriteLine(m);

            //SendCall();

            string hex = "00 90 C3 45";
            byte[] b = ConvertHelper.HexToBytes(hex);

            var s = ((b[0] & 0xFF) | ((b[1] & 0xFF) << 8) | ((b[2] & 0xFF) << 16) | ((b[3] & 0xFF) << 24));
            float f1 = Convert.ToSingle(s);

            float f2 = ConvertHelper.GetHexFloat("0090C345");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

        //static int ReceiveSeqNum = 6;
        //static int SendSeqNum = 2;
        //static void SendCall()
        //{
        //    try
        //    {
        //        byte[] recNum = new byte[2];
        //        recNum[0] = (byte)(ReceiveSeqNum << 1);
        //        recNum[1] = (byte)(ReceiveSeqNum >> 7);
        //        string recStr = ConvertHelper.ToHexString(recNum);
        //        byte[] sendNum = new byte[2];
        //        sendNum[0] = (byte)(SendSeqNum << 1);
        //        sendNum[1] = (byte)(SendSeqNum >> 7);
        //        SendSeqNum += 1;
        //        string sendStr = ConvertHelper.ToHexString(sendNum);
        //        //SendToServer("680E" + sendStr + recStr + "64010600010000000014");
        //    }
        //    catch (Exception ex)
        //    {
        //        //AddListBoxItem(ex.Message);
        //    }
        //}

    }
}
